"use strict";
cc._RF.push(module, '46249VJ57lEerldykDyZXUP', 'leve_bunchbunchbunch');
// scripts/levelBundles/level_bunchbunch/leve_bunchbunchbunch.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
Object.defineProperty(exports, "__esModule", { value: true });
var LevelBase_1 = require("../../Game/Base/LevelBase");
var Enum_1 = require("../../Game/Enum");
var MainRoot_1 = require("../../Game/MainRoot");
var gameEngine_1 = require("../../engines/gameEngine");
var CsvFileKind_1 = require("../../engines/libs/CsvFileKind");
var data_control_1 = require("../../engines/libs/data_control");
var level_bunchAnimalGroup_1 = require("./level_bunchAnimalGroup");
var level_bunchAnimalItem_1 = require("./level_bunchAnimalItem");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var level_bunchbunchbunch = /** @class */ (function (_super) {
    __extends(level_bunchbunchbunch, _super);
    function level_bunchbunchbunch() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.gameContent = null;
        _this.groupPrefab = null;
        _this.animalPrefab = null;
        _this.doorPrefab = null;
        _this.glassPrefab = null;
        _this.doorContent = null;
        _this.groupContent = null;
        _this.animalContent = null;
        _this.glassContent = null;
        _this.touchNode = null;
        /**关卡数据 */
        _this.levelData = null;
        /**当前选中的节点 */
        _this.curSelectNode = null;
        /**是否可以点击 */
        _this.canTouch = true;
        /**初始的所有动物 */
        _this.initAnimals = [];
        /**倒计时 */
        _this.countDown = 0;
        /**游戏中界面 */
        _this.inGamePage = null;
        /**游戏是否暂停 */
        _this.gamePauseFlag = false;
        _this.maxCount = 0;
        _this.spPathAry = [
            "chuan_dongwu_1",
            "chuan_dongwu_2",
            "chuan_dongwu_3",
            "chuan_dongwu_4"
        ];
        return _this;
    }
    level_bunchbunchbunch.prototype.Init = function (info) {
        return __awaiter(this, void 0, Promise, function () {
            var inGamePrams, page;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        this.levelInfo = info;
                        this.m_mode = info.mode;
                        this.tips = info.tips;
                        inGamePrams = {
                            mode: this.m_mode,
                            levelInfo: this.levelInfo,
                            title: info.title,
                            tips: info.tips,
                            hideTitle: info.hideTitle
                        };
                        gameEngine_1.default.on(Enum_1.GAME_EVENT.ON_BTN_TIPS, this.OnTips.bind(this));
                        this.levelData = gameEngine_1.default.getManagers().csvDataManager.getCsvDataItem(CsvFileKind_1.CsvFileKind.CsvFile.bunchbunchbunchLevel, this.levelInfo.level);
                        this.countDown = Number(this.levelData["time"]);
                        this.spPathAry = data_control_1.default.randomSortArray(this.spPathAry);
                        return [4 /*yield*/, MainRoot_1.default.UISystem.OpenPage(Enum_1.PAGE.BUNCH_INGAME_PAGE, inGamePrams)];
                    case 1:
                        page = _a.sent();
                        this.inGamePage = page;
                        this.inGamePage.bindLevel(this);
                        return [4 /*yield*/, this.loadGroup()];
                    case 2:
                        _a.sent();
                        return [4 /*yield*/, this.loadAnimal()];
                    case 3:
                        _a.sent();
                        this.startCountDown();
                        return [2 /*return*/];
                }
            });
        });
    };
    level_bunchbunchbunch.prototype.loadGroup = function () {
        return __awaiter(this, void 0, void 0, function () {
            var _this = this;
            return __generator(this, function (_a) {
                return [2 /*return*/, new Promise(function (resolve) {
                        var animals = _this.levelData["animal_id"].split("&");
                        var maxCount = _this.maxCount = Number(_this.levelData["max_animal_count"]);
                        var groupCount = animals.length;
                        _this.gameContent.scale = animals.length > 4 ? 0.85 : 1;
                        var posAry1 = [cc.v2(-285, 0), cc.v2(-95, 0), cc.v2(95, 0), cc.v2(285, 0)];
                        var posAry2 = [cc.v2(-340, 0), cc.v2(-170, 0), cc.v2(0, 0), cc.v2(170, 0), cc.v2(340, 0)];
                        var posAry = animals.length > 4 ? posAry2 : posAry1;
                        var ary = [];
                        for (var i = 0; i < groupCount; i++) {
                            var group = cc.instantiate(_this.groupPrefab);
                            var gs = group.getComponent(level_bunchAnimalGroup_1.default);
                            gs.setMaxCount(maxCount);
                            gs.bindTag(_this, i);
                            ary.push(group);
                            _this.initAnimals[i] = [];
                        }
                        ary = data_control_1.default.randomSortArray(ary);
                        for (var i = 0; i < ary.length; i++) {
                            var pos = posAry[i];
                            var group = ary[i];
                            group.setParent(_this.groupContent);
                            group.setPosition(pos);
                        }
                        var posYAry = _this.getPos(_this.maxCount);
                        for (var i = 0; i < ary.length; i++) {
                            var door = cc.instantiate(_this.doorPrefab);
                            door.parent = _this.doorContent;
                            door.setPosition(posAry[i].x, posYAry[posYAry.length - 1] + 85);
                            door.active = false;
                            var glassNode = cc.instantiate(_this.glassPrefab);
                            glassNode.setParent(_this.glassContent);
                            glassNode.setPosition(posAry[i]);
                            glassNode.height = 5 + 80 * maxCount;
                            glassNode.y -= 25;
                        }
                        _this.scheduleOnce(resolve);
                    })];
            });
        });
    };
    level_bunchbunchbunch.prototype.loadAnimal = function () {
        return __awaiter(this, void 0, void 0, function () {
            var animals, animalCounts, posYAry, i, curGroupAnimal, curGroupAnimalCount, animalTypeAry, animalCountAry, group, j, type, count, k, animal, as, pos;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        if (!this.levelData) return [3 /*break*/, 9];
                        animals = this.levelData["animal_id"].split("&");
                        animalCounts = this.levelData["animal_count"].split("&");
                        posYAry = this.getPos(this.maxCount);
                        i = 0;
                        _a.label = 1;
                    case 1:
                        if (!(i < animals.length)) return [3 /*break*/, 8];
                        curGroupAnimal = animals[i];
                        curGroupAnimalCount = animalCounts[i];
                        animalTypeAry = curGroupAnimal.split("|");
                        animalCountAry = curGroupAnimalCount.split("|");
                        group = this.getOneGroupByTag(i);
                        j = animalTypeAry.length - 1;
                        _a.label = 2;
                    case 2:
                        if (!(j >= 0)) return [3 /*break*/, 7];
                        type = animalTypeAry[j];
                        count = Number(animalCountAry[j]);
                        k = 0;
                        _a.label = 3;
                    case 3:
                        if (!(k < count)) return [3 /*break*/, 6];
                        animal = cc.instantiate(this.animalPrefab);
                        as = animal.getComponent(level_bunchAnimalItem_1.default);
                        as.bindType(type, this);
                        pos = cc.v2(group.node.x, posYAry[group.animalAry.length]);
                        group && group.addAnimal(as);
                        animal.setParent(this.animalContent);
                        // this.scheduleOnce(()=>{
                        animal.setPosition(pos);
                        // })
                        this.initAnimals[i].push(as);
                        return [4 /*yield*/, new Promise(function (resolve) {
                                resolve();
                            })];
                    case 4:
                        _a.sent();
                        _a.label = 5;
                    case 5:
                        k++;
                        return [3 /*break*/, 3];
                    case 6:
                        j--;
                        return [3 /*break*/, 2];
                    case 7:
                        i++;
                        return [3 /*break*/, 1];
                    case 8:
                        this.touchNode.on("touchend", this.onTouchEnd, this);
                        _a.label = 9;
                    case 9: return [2 /*return*/];
                }
            });
        });
    };
    level_bunchbunchbunch.prototype.onTouchEnd = function (e) {
        return __awaiter(this, void 0, void 0, function () {
            var targetNode, cs, cs, cs_1, ts_1, cMoveAnimals_1, pushCardFlag_1, moveOverFlag_1, moveAnimals_1, moveCount_1;
            var _this = this;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        if (!this.canTouch) {
                            return [2 /*return*/];
                        }
                        this.canTouch = false;
                        targetNode = null;
                        this.groupContent.children.forEach(function (n) {
                            var nBound = n.getBoundingBoxToWorld();
                            if (nBound.contains(e.getLocation())) {
                                targetNode = n;
                            }
                        });
                        if (!!targetNode) return [3 /*break*/, 3];
                        if (!this.curSelectNode) return [3 /*break*/, 2];
                        cs = this.curSelectNode.getComponent(level_bunchAnimalGroup_1.default);
                        // 选择动物取消选择
                        return [4 /*yield*/, this.selectOneGroup(cs, false)];
                    case 1:
                        // 选择动物取消选择
                        _a.sent();
                        _a.label = 2;
                    case 2:
                        this.curSelectNode = null;
                        this.canTouch = true;
                        return [2 /*return*/];
                    case 3:
                        gameEngine_1.default.getManagers().soundMgr.playSound("mainSound/anNiu");
                        if (!!this.curSelectNode) return [3 /*break*/, 5];
                        this.curSelectNode = targetNode;
                        cs = this.curSelectNode.getComponent(level_bunchAnimalGroup_1.default);
                        if (cs.checkGroupIsVaild()) {
                            this.canTouch = true;
                            return [2 /*return*/];
                        }
                        // 设置动物为选择状态
                        return [4 /*yield*/, this.selectOneGroup(cs, true)];
                    case 4:
                        // 设置动物为选择状态
                        _a.sent();
                        return [3 /*break*/, 12];
                    case 5:
                        cs_1 = this.curSelectNode.getComponent(level_bunchAnimalGroup_1.default);
                        ts_1 = targetNode.getComponent(level_bunchAnimalGroup_1.default);
                        if (ts_1.checkGroupIsVaild()) {
                            this.canTouch = true;
                            return [2 /*return*/];
                        }
                        if (!(targetNode.uuid == this.curSelectNode.uuid)) return [3 /*break*/, 7];
                        // 设置动物为非选中状态
                        return [4 /*yield*/, this.selectOneGroup(cs_1, false)];
                    case 6:
                        // 设置动物为非选中状态
                        _a.sent();
                        this.curSelectNode = null;
                        this.canTouch = true;
                        return [2 /*return*/];
                    case 7:
                        cMoveAnimals_1 = cs_1.getMoveAnimals();
                        pushCardFlag_1 = false;
                        moveOverFlag_1 = false;
                        moveAnimals_1 = [];
                        moveCount_1 = 0;
                        return [4 /*yield*/, new Promise(function (resolve) {
                                var a = cMoveAnimals_1[0];
                                if (!ts_1.checkCanAddAnimal(a)) {
                                    ts_1.setHintLb("动\n物\n不\n同\n不\n能\n放\n入");
                                    _this.canTouch = true;
                                    resolve();
                                    return;
                                }
                                if (cMoveAnimals_1.length <= ts_1.getCanAddAnimalCount()) {
                                    var _loop_1 = function (i) {
                                        var animal = cMoveAnimals_1[i];
                                        if (ts_1.checkCanAddAnimal(animal)) {
                                            if (i == cMoveAnimals_1.length - 1) {
                                                moveOverFlag_1 = true;
                                            }
                                            pushCardFlag_1 = true;
                                            moveAnimals_1.push(animal);
                                            moveCount_1++;
                                            // 动物取消选择状态
                                            // cs.spliceAnimal(animal);
                                            // ts.addAnimal(animal);
                                            cs_1.spliceAnimal(animal);
                                            ts_1.addAnimal(animal);
                                            _this.pushAnimalToGroupAni(cs_1, ts_1, animal).then(function () {
                                                if (i == moveCount_1 - 1) {
                                                    resolve();
                                                    _this.checkGameIsWin();
                                                }
                                            });
                                        }
                                    };
                                    // 可以放入
                                    for (var i = 0; i < cMoveAnimals_1.length; i++) {
                                        _loop_1(i);
                                    }
                                    if (moveCount_1 == 0) {
                                        resolve();
                                    }
                                }
                                else {
                                    resolve();
                                    // 提示放不进去 满了
                                    ts_1.setHintLb("栅\n栏\n已\n满");
                                    return;
                                }
                            })];
                    case 8:
                        _a.sent();
                        if (!!pushCardFlag_1) return [3 /*break*/, 9];
                        // 没有移动卡牌 切换选择的卡牌
                        this.selectOneGroup(cs_1, false);
                        // await this.selectOneGroup(ts,true);
                        this.curSelectNode = null;
                        return [3 /*break*/, 12];
                    case 9:
                        if (!!moveOverFlag_1) return [3 /*break*/, 11];
                        return [4 /*yield*/, this.selectOneGroup(cs_1, false)];
                    case 10:
                        _a.sent();
                        _a.label = 11;
                    case 11:
                        this.curSelectNode = null;
                        _a.label = 12;
                    case 12:
                        this.canTouch = true;
                        return [2 /*return*/];
                }
            });
        });
    };
    level_bunchbunchbunch.prototype.getOneGroupByTag = function (tag) {
        var _a;
        return (_a = this.groupContent.children.find(function (node) {
            var ns = node.getComponent(level_bunchAnimalGroup_1.default);
            return ns.groupTag == tag;
        })) === null || _a === void 0 ? void 0 : _a.getComponent(level_bunchAnimalGroup_1.default);
    };
    level_bunchbunchbunch.prototype.pushAnimalToGroupAni = function (oneGroup, targetGroup, animal) {
        return __awaiter(this, void 0, void 0, function () {
            var posYAry, ty;
            return __generator(this, function (_a) {
                posYAry = this.getPos(this.maxCount);
                ty = posYAry[targetGroup.animalAry.length - 1];
                return [2 /*return*/, new Promise(function (resolve) {
                        var oneX = oneGroup.node.x;
                        var oneY = posYAry[posYAry.length - 1] + 100;
                        var targetX = targetGroup.node.x;
                        var targetY = ty;
                        var moveSpd = 700;
                        var oneTime = Math.abs(oneY - animal.node.y) / moveSpd;
                        var twoTime = Math.abs(oneX - targetX) / moveSpd;
                        var threeTime = (oneY - targetY) / moveSpd;
                        cc.tween(animal.node).to(oneTime, { y: oneY }).to(twoTime, { x: targetX }).to(threeTime, { y: targetY }).call(function () {
                            resolve();
                        }).start();
                    })];
            });
        });
    };
    level_bunchbunchbunch.prototype.selectOneGroup = function (group, selectFlag) {
        return __awaiter(this, void 0, void 0, function () {
            var _this = this;
            return __generator(this, function (_a) {
                return [2 /*return*/, new Promise(function (resolve) {
                        var moveAnimals = group.getMoveAnimals();
                        if (moveAnimals.length <= 0) {
                            resolve();
                            return;
                        }
                        var lastIndex = group.animalAry.length - 1;
                        var posYAry = _this.getPos(_this.maxCount);
                        var ty = posYAry[lastIndex];
                        var pos = cc.v2(0, ty);
                        var dis = pos.sub(cc.v2(0, posYAry[posYAry.length - 1] + 100)).mag();
                        var speed = 1000;
                        var needTime = dis / speed;
                        if (selectFlag) {
                            for (var _i = 0, moveAnimals_2 = moveAnimals; _i < moveAnimals_2.length; _i++) {
                                var animal = moveAnimals_2[_i];
                                cc.tween(animal.node).by(needTime, { y: dis }).call(resolve).start();
                            }
                        }
                        else {
                            for (var _a = 0, moveAnimals_3 = moveAnimals; _a < moveAnimals_3.length; _a++) {
                                var animal = moveAnimals_3[_a];
                                var index = group.checkIndexByAnimal(animal);
                                var posY = posYAry[index];
                                needTime = Math.abs(posY - animal.node.y) / speed;
                                console.log(posY, "zmges", animal.node.y, needTime);
                                cc.tween(animal.node).to(needTime, { y: posY }).call(resolve).start();
                            }
                        }
                    })];
            });
        });
    };
    level_bunchbunchbunch.prototype.initGame = function () {
        this.curSelectNode = null;
        var posYAry = this.getPos(this.maxCount);
        this.doorContent.children.forEach(function (n) {
            n.active = false;
        });
        this.groupContent.children.forEach(function (n) {
            var ns = n.getComponent(level_bunchAnimalGroup_1.default);
            ns.closeDoorFlag = false;
        });
        for (var i = 0; i < this.initAnimals.length; i++) {
            var group = this.getOneGroupByTag(i);
            group.animalAry = this.initAnimals[i].concat();
            for (var j = 0; j < this.initAnimals[i].length; j++) {
                var animal = this.initAnimals[i][j];
                var index = group.checkIndexByAnimal(animal);
                var pos = cc.v2(group.node.x, posYAry[index]);
                animal.node.setPosition(pos);
            }
        }
    };
    level_bunchbunchbunch.prototype.OnTips = function () {
        this.inGamePage.hideTipsBtn();
        this.stopCountDown();
        this.startAuto();
    };
    level_bunchbunchbunch.prototype.startAuto = function () {
        return __awaiter(this, void 0, void 0, function () {
            var stepAry, _loop_2, this_1, i;
            var _this = this;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        this.initGame();
                        this.canTouch = false;
                        this.gamePauseFlag = true;
                        stepAry = this.levelData["hint_step"].split("&");
                        _loop_2 = function (i) {
                            var stepStr, step, oneGroupId, targetGroupId, oneGroup, targetGroup, moveAnimals;
                            return __generator(this, function (_a) {
                                switch (_a.label) {
                                    case 0:
                                        stepStr = stepAry[i];
                                        step = stepStr.split("-");
                                        oneGroupId = Number(step[0]) - 1;
                                        targetGroupId = Number(step[1]) - 1;
                                        oneGroup = this_1.getOneGroupByTag(oneGroupId);
                                        targetGroup = this_1.getOneGroupByTag(targetGroupId);
                                        moveAnimals = oneGroup.getMoveAnimals();
                                        return [4 /*yield*/, new Promise(function (resolve) {
                                                var moveCount = 0;
                                                var _loop_3 = function (i_1) {
                                                    var animal = moveAnimals[i_1];
                                                    if (targetGroup.checkCanAddAnimal(animal)) {
                                                        moveCount++;
                                                        // 动物取消选择状态
                                                        oneGroup.spliceAnimal(animal);
                                                        targetGroup.addAnimal(animal);
                                                        _this.pushAnimalToGroupAni(oneGroup, targetGroup, animal).then(function () {
                                                            if (i_1 == moveCount - 1) {
                                                                resolve();
                                                                _this.checkGameIsWin();
                                                            }
                                                        });
                                                    }
                                                    else {
                                                        return "break";
                                                    }
                                                };
                                                for (var i_1 = 0; i_1 < moveAnimals.length; i_1++) {
                                                    var state_1 = _loop_3(i_1);
                                                    if (state_1 === "break")
                                                        break;
                                                }
                                                if (moveCount == 0) {
                                                    resolve();
                                                }
                                            })];
                                    case 1:
                                        _a.sent();
                                        return [2 /*return*/];
                                }
                            });
                        };
                        this_1 = this;
                        i = 0;
                        _a.label = 1;
                    case 1:
                        if (!(i < stepAry.length)) return [3 /*break*/, 4];
                        return [5 /*yield**/, _loop_2(i)];
                    case 2:
                        _a.sent();
                        _a.label = 3;
                    case 3:
                        i++;
                        return [3 /*break*/, 1];
                    case 4: return [2 /*return*/];
                }
            });
        });
    };
    level_bunchbunchbunch.prototype.startCountDown = function () {
        this.schedule(this.subCountDown, 1);
    };
    level_bunchbunchbunch.prototype.subCountDown = function () {
        if (this.gamePauseFlag) {
            return;
        }
        this.countDown--;
        this.inGamePage.refrenshCountDown();
        if (this.countDown <= 0) {
            this.stopCountDown();
            this.canTouch = false;
            this.Lose(2);
        }
    };
    level_bunchbunchbunch.prototype.stopCountDown = function () {
        this.unschedule(this.subCountDown);
    };
    level_bunchbunchbunch.prototype.checkGameIsWin = function () {
        var isWin = true;
        this.groupContent.children.forEach(function (n) {
            var ns = n.getComponent(level_bunchAnimalGroup_1.default);
            if (!ns.checkGroupIsVaild() && ns.animalAry.length != 0) {
                isWin = false;
            }
        });
        this.closeDoor();
        if (isWin) {
            this.Win(2);
        }
    };
    level_bunchbunchbunch.prototype.getPos = function (maxCount) {
        var posAry = [];
        var inveter = maxCount % 2 == 0 ? 80 / 2 : 0;
        if (maxCount % 2 != 0) {
            posAry.push(0);
        }
        var roundLength = Math.floor(maxCount / 2);
        for (var i = 0; i < roundLength; i++) {
            var one = (i + 1) * 80 - inveter;
            var two = -((i + 1) * 80 - inveter);
            posAry.push(one);
            posAry.unshift(two);
        }
        return posAry;
    };
    level_bunchbunchbunch.prototype.closeDoor = function () {
        var _this = this;
        var nodes = [];
        this.groupContent.children.forEach(function (n) {
            var ns = n.getComponent(level_bunchAnimalGroup_1.default);
            if (ns.checkGroupIsVaild() && !ns.closeDoorFlag) {
                nodes.push(n);
                ns.closeDoorFlag = true;
            }
        });
        if (nodes.length > 0) {
            for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
                var node = nodes_1[_i];
                var sillibing = node.getSiblingIndex();
                var door = this.doorContent.children[sillibing];
                var pos = door.getPosition().clone();
                door.y += 200;
                door.active = true;
                cc.tween(door).to(0.2, { y: pos.y }).call(function () {
                    _this.canvasShark();
                }).start();
            }
        }
    };
    level_bunchbunchbunch.prototype.canvasShark = function () {
        var cameraNode = cc.find("Main Camera");
        if (cameraNode) {
            var width = 8;
            var once = cc.tween(cameraNode)
                .by(0.02, { x: width, y: width })
                .by(0.02, { x: 0, y: -width })
                .by(0.02, { x: -width, y: -width })
                .by(0.02, { x: -width, y: 0 })
                .by(0.02, { x: 0, y: width })
                .by(0.02, { x: width, y: 0 });
            //
            cc.tween(cameraNode)
                .then(once)
                .repeat(3)
                .start();
        }
    };
    __decorate([
        property({ type: cc.Node, tooltip: "游戏游玩节点" })
    ], level_bunchbunchbunch.prototype, "gameContent", void 0);
    __decorate([
        property({ type: cc.Prefab, tooltip: "组预制体" })
    ], level_bunchbunchbunch.prototype, "groupPrefab", void 0);
    __decorate([
        property({ type: cc.Prefab, tooltip: "动物预制体" })
    ], level_bunchbunchbunch.prototype, "animalPrefab", void 0);
    __decorate([
        property({ type: cc.Prefab, tooltip: "门预制体" })
    ], level_bunchbunchbunch.prototype, "doorPrefab", void 0);
    __decorate([
        property({ type: cc.Prefab, tooltip: "草预制体" })
    ], level_bunchbunchbunch.prototype, "glassPrefab", void 0);
    __decorate([
        property({ type: cc.Node, tooltip: "门content" })
    ], level_bunchbunchbunch.prototype, "doorContent", void 0);
    __decorate([
        property({ type: cc.Node, tooltip: "组content" })
    ], level_bunchbunchbunch.prototype, "groupContent", void 0);
    __decorate([
        property({ type: cc.Node, tooltip: "动物content" })
    ], level_bunchbunchbunch.prototype, "animalContent", void 0);
    __decorate([
        property({ type: cc.Node, tooltip: "草content" })
    ], level_bunchbunchbunch.prototype, "glassContent", void 0);
    __decorate([
        property({ type: cc.Node, tooltip: "点击节点" })
    ], level_bunchbunchbunch.prototype, "touchNode", void 0);
    level_bunchbunchbunch = __decorate([
        ccclass
    ], level_bunchbunchbunch);
    return level_bunchbunchbunch;
}(LevelBase_1.default));
exports.default = level_bunchbunchbunch;

cc._RF.pop();